<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // 隐式转换
    var num1 = "8"
    var num2 = "4"
    var result1 = num1 + num2
    console.log(result1, typeof result1) // 84 string
    var result2 = num1 * num2
    console.log(result2, typeof result2) // 32 'number'

    // 显式转换
    var result3 = Number(num1)
    console.log(result3, typeof result3) // 8 'number'

    console.log(Number(undefined)) // NaN
    console.log(Number(true), Number(false)) // 1 0
    console.log(Number(null)) // 0
    console.log(Number("abc123")) // NaN
    console.log(Number("   123")) // 123

  </script>
</body>

</html>